package ray.mgocc.title;

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import ray.mgocc.Record;

public class TitleList extends ArrayList<Title>{
    public TitleList(){
        init();
    }
    private void init(){
        //total
        //TSUCHINOKO
        //BIG BOSS
        //THE BOSS
        add(new FoxHound());
        add(new Fox());
        add(new Doberman());
        add(new Hound());
        //week
        add(new Pigeon());
        add(new Eagle());
        add(new Jaws());
        add(new Crocodile());
        add(new Bee());
        add(new WaterBear());
        add(new Chicken());
        add(new Tortoise());
        add(new FlyingSquirrel());
        add(new NightOwl());
        addAll(RuleTitle.getList());
        add(new Rat());
        add(new Sloth());
    }
    public void setRecord(Record record){
        for(Title title:this){
            title.setRecord(record);
        }
    }
    /** 取得できるであろう、TitleのList。 */
    public List<Title> getList(){
        List<Title> list = new ArrayList<Title>();
        for(Title title:this){
            if(title.check()){
                list.add(title);
            }
        }
        return list;
    }
    /**
     * 取得できるであろうTitleのうち、最も優先度が高いもの。
     * つまり、表示されるもの。
     */
    public Title getTitle(){
        Title max = null;
        List list = getList();
        if(!list.isEmpty()){
            max = (Title)Collections.max(list);
        }
        return max;
    }
    public Title getTitle(String name){
        Title hit = null;
        for(Title sample:this){
            if(sample.getName().equals(name)){
                hit = sample;
            }
        }
        return hit;
    }
}
